# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[self._element = element
self._ns = ns
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76662ec>}
nname: 148
n 148(None)[del _[1]
return res
]:
	i: 112(AF), 126()
	o: 

nname: 126
n 126(None)[for t in res:
]:
	i: 112(for)
	o: 148()

nname: 112
n 112(None)[]:
	i: 95(), 111()
	o: 126(for), 148(AF)

nname: 111
n 111(None)[]:
	i: 65(f)
	o: 112()

nname: 95
n 95(None)[raise KeyError(tag)
]:
	i: 65(t)
	o: 112()

nname: 65
n 65(res == [])[res = self._element.findall(tag)
]:
	i: 15(), 39()
	o: 95(t), 111(f)

nname: 39
n 39(None)[namespace = self._ns
tag = '{%s}%s' % (namespace, tag)
]:
	i: 0(f)
	o: 65()

nname: 15
n 15(None)[_[1], namespace = [], tag[0]
tag = '{%s}%s' % tag
]:
	i: 0(t)
	o: 65()

nname: 0
n 0(isinstance(tag, tuple))[]:
	i: 
	o: 15(t), 39(f)

nname: 148
n 148(None)[del _[1]
return res
]:
	i: 112(AF), 126()
	o: 

nname: 126
n 126(None)[for t in res:
]:
	i: 112(for)
	o: 148()

nname: 112
n 112(None)[]:
	i: 0()
	o: 126(for), 148(AF)

nname: 0
n 0(None)[if isinstance(tag, tuple):
	_[1], namespace = [], tag[0]
	tag = '{%s}%s' % tag
else:
	namespace = self._ns
	tag = '{%s}%s' % (namespace, tag)
res = self._element.findall(tag)
if res == []:
	raise KeyError(tag)
]:
	i: 
	o: 112()

nname: 148
n 148(None)[del _[1]
return res
]:
	i: 0(AF), 126()
	o: 

nname: 126
n 126(None)[for t in res:
]:
	i: 0(for)
	o: 148()

nname: 0
n 0(None)[if isinstance(tag, tuple):
	_[1], namespace = [], tag[0]
	tag = '{%s}%s' % tag
else:
	namespace = self._ns
	tag = '{%s}%s' % (namespace, tag)
res = self._element.findall(tag)
if res == []:
	raise KeyError(tag)
]:
	i: 
	o: 126(for), 148(AF)

self.nodes: {0: <unpyclib.structure.node instance at 0xb7666f4c>, 148: <unpyclib.structure.node instance at 0xb7666e4c>, 126: <unpyclib.structure.node instance at 0xb7666dcc>}
nname: 47
n 47(None)[return t
]:
	i: 30(), 46()
	o: 

nname: 46
n 46(None)[]:
	i: 0(f)
	o: 47()

nname: 30
n 30(None)[raise AttributeError(tag)
]:
	i: 0(t)
	o: 47()

nname: 0
n 0(t is None)[t = self._element.findtext(tag)
]:
	i: 
	o: 30(t), 46(f)

nname: 0
n 0(None)[t = self._element.findtext(tag)
if t is None:
	raise AttributeError(tag)
return t
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb766656c>}
nname: 6
n 6(None)[__slots__ = ['_element', '_ns']
def __init__(self, element, ns=''):
	self._element = element
	self._ns = ns

_attr = property()
_list = property()
def __getitem__(self, tag):
	if isinstance(tag, tuple):
		_[1], namespace = [], tag[0]
		tag = '{%s}%s' % tag
	else:
		namespace = self._ns
		tag = '{%s}%s' % (namespace, tag)
	res = self._element.findall(tag)
	if res == []:
		raise KeyError(tag)

def __getattr__(self, tag):
	t = self._element.findtext(tag)
	if t is None:
		raise AttributeError(tag)
	return t

_thumbnail_uri = property()
_video_uri = property()
]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb765fe2c>}
nname: 94
n 94(None)[del _[1]
for self._items in channel.findall(item_name):
]:
	i: 0(AF), 75()
	o: 

nname: 75
n 75(None)[for i in channel.findall(item_name):
]:
	i: 0(for)
	o: 94()

nname: 0
n 0(None)[feed = ET.parse(in_file).getroot()
channel = feed.find(channel_name)
ElementWrapper.__init__(self, channel)
]:
	i: 
	o: 75(for), 94(AF)

self.nodes: {0: <unpyclib.structure.node instance at 0xb765fa0c>, 75: <unpyclib.structure.node instance at 0xb765ff4c>, 94: <unpyclib.structure.node instance at 0xb766664c>}
nname: 0
n 0(None)[return iter(self._items)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb765f8ec>}
nname: 6
n 6(None)[def __init__(self, in_file, channel_name='channel', item_name='item'):
	feed = ET.parse(in_file).getroot()
	channel = feed.find(channel_name)
	ElementWrapper.__init__(self, channel)

def __iter__(self):
	return iter(self._items)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb765f70c>}
nname: 0
n 0(None)[import urllib2
self.urlopen = urllib2.build_opener(urllib2.HTTPCookieProcessor(), urllib2.ProxyHandler()).open
self.site = 'http://www.dailymotion.com/rss/'
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb765ff4c>}
nname: 101
n 101(None)[uri += '%d:%d' % (page, max_res)
return RSSWrapper(self.urlopen(uri))
]:
	i: 52(), 73()
	o: 

nname: 73
n 73(None)[uri += self._sections[section] % quote_plus(pattern)
]:
	i: 40(f)
	o: 101()

nname: 52
n 52(None)[uri += self._sections[section]
]:
	i: 40(t)
	o: 101()

nname: 40
n 40(pattern is None)[]:
	i: 21(), 39()
	o: 52(t), 73(f)

nname: 39
n 39(None)[]:
	i: 0(f)
	o: 40()

nname: 21
n 21(None)[uri += lang + '/'
]:
	i: 0(t)
	o: 40()

nname: 0
n 0(lang is not None)[uri = self.site
]:
	i: 
	o: 21(t), 39(f)

nname: 101
n 101(None)[uri += '%d:%d' % (page, max_res)
return RSSWrapper(self.urlopen(uri))
]:
	i: 0()
	o: 

nname: 0
n 0(None)[uri = self.site
if lang is not None:
	uri += lang + '/'
if pattern is None:
	uri += self._sections[section]
else:
	uri += self._sections[section] % quote_plus(pattern)
]:
	i: 
	o: 101()

nname: 0
n 0(None)[uri = self.site
if lang is not None:
	uri += lang + '/'
if pattern is None:
	uri += self._sections[section]
else:
	uri += self._sections[section] % quote_plus(pattern)
uri += '%d:%d' % (page, max_res)
return RSSWrapper(self.urlopen(uri))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7666fac>}
nname: 6
n 6(None)[def __init__(self):
	import urllib2
	self.urlopen = urllib2.build_opener(urllib2.HTTPCookieProcessor(), urllib2.ProxyHandler()).open
	self.site = 'http://www.dailymotion.com/rss/'

_sections = ['', 'videos/relevance/search/%s/', 'cluster/news/', 'official/', 'creative/']
def search(self, pattern=None, sortby=None, page=1, max_res=20, lang=None, section=1):
	uri = self.site
	if lang is not None:
		uri += lang + '/'
	if pattern is None:
		uri += self._sections[section]
	else:
		uri += self._sections[section] % quote_plus(pattern)
	uri += '%d:%d' % (page, max_res)
	return RSSWrapper(self.urlopen(uri))

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb765fb4c>}
nname: 0
n 0(None)[__all__ = ['DailyMotionBrowser', 'RSSWrapper']
import xml.etree.cElementTree as ET
from urllib import quote_plus
NS_itunes = 'http://www.itunes.com/dtds/podcast-1.0.dtd'
NS_media = 'http://search.yahoo.com/mrss'
NS_dm = 'http://www.dailymotion.com/dmrss'
class ElementWrapper(object):
	__slots__ = ['_element', '_ns']
	def __init__(self, element, ns=''):
		self._element = element
		self._ns = ns

	_attr = property()
	_list = property()
	def __getitem__(self, tag):
		if isinstance(tag, tuple):
			_[1], namespace = [], tag[0]
			tag = '{%s}%s' % tag
		else:
			namespace = self._ns
			tag = '{%s}%s' % (namespace, tag)
		res = self._element.findall(tag)
		if res == []:
			raise KeyError(tag)

	def __getattr__(self, tag):
		t = self._element.findtext(tag)
		if t is None:
			raise AttributeError(tag)
		return t

	_thumbnail_uri = property()
	_video_uri = property()


class RSSWrapper(ElementWrapper):
	def __init__(self, in_file, channel_name='channel', item_name='item'):
		feed = ET.parse(in_file).getroot()
		channel = feed.find(channel_name)
		ElementWrapper.__init__(self, channel)

	def __iter__(self):
		return iter(self._items)



class DailyMotionBrowser(object):
	def __init__(self):
		import urllib2
		self.urlopen = urllib2.build_opener(urllib2.HTTPCookieProcessor(), urllib2.ProxyHandler()).open
		self.site = 'http://www.dailymotion.com/rss/'

	_sections = ['', 'videos/relevance/search/%s/', 'cluster/news/', 'official/', 'creative/']
	def search(self, pattern=None, sortby=None, page=1, max_res=20, lang=None, section=1):
		uri = self.site
		if lang is not None:
			uri += lang + '/'
		if pattern is None:
			uri += self._sections[section]
		else:
			uri += self._sections[section] % quote_plus(pattern)
		uri += '%d:%d' % (page, max_res)
		return RSSWrapper(self.urlopen(uri))



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7658b6c>}
__all__ = ['DailyMotionBrowser', 'RSSWrapper']
import xml.etree.cElementTree as ET
from urllib import quote_plus
NS_itunes = 'http://www.itunes.com/dtds/podcast-1.0.dtd'
NS_media = 'http://search.yahoo.com/mrss'
NS_dm = 'http://www.dailymotion.com/dmrss'
class ElementWrapper(object):
	__slots__ = ['_element', '_ns']
	def __init__(self, element, ns=''):
		self._element = element
		self._ns = ns

	_attr = property()
	_list = property()
	def __getitem__(self, tag):
		if isinstance(tag, tuple):
			_[1], namespace = [], tag[0]
			tag = '{%s}%s' % tag
		else:
			namespace = self._ns
			tag = '{%s}%s' % (namespace, tag)
		res = self._element.findall(tag)
		if res == []:
			raise KeyError(tag)

	def __getattr__(self, tag):
		t = self._element.findtext(tag)
		if t is None:
			raise AttributeError(tag)
		return t

	_thumbnail_uri = property()
	_video_uri = property()


class RSSWrapper(ElementWrapper):
	def __init__(self, in_file, channel_name='channel', item_name='item'):
		feed = ET.parse(in_file).getroot()
		channel = feed.find(channel_name)
		ElementWrapper.__init__(self, channel)

	def __iter__(self):
		return iter(self._items)



class DailyMotionBrowser(object):
	def __init__(self):
		import urllib2
		self.urlopen = urllib2.build_opener(urllib2.HTTPCookieProcessor(), urllib2.ProxyHandler()).open
		self.site = 'http://www.dailymotion.com/rss/'

	_sections = ['', 'videos/relevance/search/%s/', 'cluster/news/', 'official/', 'creative/']
	def search(self, pattern=None, sortby=None, page=1, max_res=20, lang=None, section=1):
		uri = self.site
		if lang is not None:
			uri += lang + '/'
		if pattern is None:
			uri += self._sections[section]
		else:
			uri += self._sections[section] % quote_plus(pattern)
		uri += '%d:%d' % (page, max_res)
		return RSSWrapper(self.urlopen(uri))



